package com.lanyeo.liver.util

import android.graphics.Point
import android.os.Parcel
import android.os.Parcelable

class TouchAction() : Parcelable {
    var start = Point(0, 0)
    var end = Point(0, 0)
    var waitTime = 100
    var durationTime = 100
    var isContinuous = false
    constructor(touchPoint: Point, waitTime: Int = 250, durationTime: Int = 100) : this() {
        start = touchPoint
        this.waitTime = waitTime
        this.durationTime = durationTime
    }
    constructor(startPoint: Point, endPoint: Point, durationTime: Int, isContinuous:Boolean = true) : this() {
        start = startPoint
        end = endPoint
        this.durationTime = durationTime
        this.isContinuous = isContinuous
    }
    constructor(startPoint: Point, endPoint: Point, waitTime: Int, durationTime: Int, isContinuous:Boolean = true) : this() {
        start = startPoint
        end = endPoint
        this.waitTime = waitTime
        this.durationTime = durationTime
        this.isContinuous = isContinuous
    }
    constructor(parcel: Parcel) : this() {
        start.x = parcel.readInt()
        start.y = parcel.readInt()
        end.x = parcel.readInt()
        end.y = parcel.readInt()
        waitTime = parcel.readInt()
        durationTime = parcel.readInt()
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeInt(start.x)
        parcel.writeInt(start.y)
        parcel.writeInt(end.x)
        parcel.writeInt(end.y)
        parcel.writeInt(waitTime)
        parcel.writeInt(durationTime)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<TouchAction> {
        override fun createFromParcel(parcel: Parcel): TouchAction {
            return TouchAction(parcel)
        }

        override fun newArray(size: Int): Array<TouchAction?> {
            return arrayOfNulls(size)
        }
    }
}